package com.jml.entity;

import lombok.Data;

import java.util.Objects;

@Data
public class ServiceInstance implements Comparable {
    /**
     * 服务名称
     */
    private String serviceName;
    /**
     * 服务地址
     */
    private String serviceAddres;
    /**
     * 服务最后续约时间,如果是注册的时候，这个时间就是当前时间
     */
    private long lastRenewalTime;

    public ServiceInstance(String serviceName, String serviceAddres, long lastRenewalTime) {
        this.serviceName = serviceName;
        this.serviceAddres = serviceAddres;
        this.lastRenewalTime = lastRenewalTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ServiceInstance that = (ServiceInstance) o;
        return serviceName.equals(that.serviceName) && serviceAddres.equals(that.serviceAddres);
    }

    @Override
    public int hashCode() {
        return Objects.hash(serviceName, serviceAddres);
    }

    @Override
    public int compareTo(Object o) {
        return 0;
    }
}
